//
//  BaseButton.m
//  Golf
//
//  Created by 王竞成 on 16/4/17.
//  Copyright © 2016年 刘俊. All rights reserved.
//

#import "BaseButton.h"

@implementation BaseButton
- (id)initWithFrame:(CGRect)frame

{
    
    self = [super initWithFrame:frame];
    
    if (self) {
        
        self.backgroundColor = [UIColor whiteColor];
        self.titleLabel.textAlignment=NSTextAlignmentCenter;
        
        self.titleLabel.font=[UIFont systemFontOfSize:12.0];
        
        self.imageView.contentMode=UIViewContentModeCenter;
        
        self.layer.borderWidth = 1;
        self.layer.borderColor = [kColorRGB(216, 216, 216) CGColor];;
        
    }
    
    return self;
    
}
//根据button的rect设定并返回文本label的rect

- (CGRect)titleRectForContentRect:(CGRect)contentRect

{
    
    CGFloat titleW = contentRect.size.width;
    
    CGFloat titleH = contentRect.size.height/3;
    
    CGFloat titleX = 0;
    
    CGFloat titleY = contentRect.size.height/3*2;
    
    
    
    contentRect = (CGRect){{titleX,titleY},{titleW,titleH}};
    
    return contentRect;
    
}
//根据button的rect设定并返回UIImageView的rect

- (CGRect)imageRectForContentRect:(CGRect)contentRect

{
    
    CGFloat imageW = contentRect.size.width;
    
    CGFloat imageH = contentRect.size.height/3*2;
    
    CGFloat imageX = 0;
    
    CGFloat imageY = 1;
    
    
    
    contentRect = (CGRect){{imageX,imageY},{imageW,imageH}};
    
    return contentRect;
    
}

@end
